import 'package:flutter/material.dart';

final Map renderKeys = {
  "DAY": {
    "Processing Fee": "preServiceFee",
    "GST (18% on processing fee)": "gst",
    "Total Interest Payable": "interest",
    "Amount Received": "receivedAmount",
    "Total Repayment": "totalRepayment"
  },
  "MONTH": {
    "Processing Fee": "preServiceFee",
    "GST (18% on processing fee)": "gst",
    "Amount Received": "receivedAmount",
    "EMI payable per month": "receivedAmount"
  }
};

final TextStyle keyStyle = TextStyle(color: Color(0xFF666666), fontSize: 12);
final TextStyle valueStyle = TextStyle(color: Color(0xFF101010), fontSize: 12);

class ProductDetail extends StatelessWidget {
  final Map product;

  const ProductDetail({Key key, this.product}) : super(key: key);

  List<Padding> _getListItem() {
    List<Padding> children = new List();
    if (product != null && product.isNotEmpty) {
      renderKeys[product['tenorUnit']].forEach((key, value) => {
            children.add(Padding(
              padding: EdgeInsets.only(bottom: 10),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Text(
                    key,
                    style: keyStyle,
                  ),
                  Text(
                    '${product['$value']}',
                    style: valueStyle,
                  )
                ],
              ),
            ))
          });
    }
    return children;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          color: Color(0xFFF8F9FC),
          borderRadius: BorderRadius.all(Radius.circular(12.0))),
      padding: EdgeInsets.only(top: 10, right: 10, left: 10),
      child: Column(children: _getListItem()),
    );
  }
}
